<?php
/**
 * Created by PhpStorm.
 * User: tangchao
 * Date: 19-3-27
 * Time: 下午4:01
 */

namespace App\Lib\Redis;


use EasySwoole\Core\AbstractInterface\Singleton;

class Redis
{
    use Singleton;

    public $redis = '';

    private function __construct()
    {
        ini_set('default_socket_timeout', -1);
        if(!extension_loaded('redis')) {
            throw new \Exception("redis.so文件不存在");
        }
        try {
            $this->redis = new \Predis\Client(\Yaconf::get('easyswoole.redis'));
        } catch(\Exception $e) {
            throw new \Exception("redis服务异常");
        }
    }

    public function __call($name, $arguments) {
        //可变参数
        return $this->redis->$name(...$arguments);
    }


}